<template>
  <footer class="footer">
    <span class="todo-count">剩余<strong>{{ list.length }}</strong></span>
    <ul class="filters" @click="changeShow">
      <li>
        <a :class="{selected: flag === 'all'}" href="javascript:;" @click="flag = 'all'">全部</a>
      </li>
      <li>
        <a :class="{selected: flag === 'no'}" href="javascript:;" @click="flag = 'no'">未完成</a>
      </li>
      <li>
        <a :class="{selected: flag === 'yes'}" href="javascript:;" @click="flag = 'yes'">已完成</a>
      </li>
    </ul>
    <button class="clear-completed" @click="delTrue">清除已完成</button>
  </footer>
</template>

<script>
export default {
  props: {
    list: Array
  },
  data() {
    return {
      flag: 'all'
    }
  },
  computed: {
    count(){
      return this.list.length
    }
  },
  methods: {
    changeShow() {
      this.$emit('changeShow', this.flag)
    },
    delTrue(){
      this.$emit('delTrue')
    }
  },
}
</script>